package com.tiantian.app.activities;

import com.infindo.frame.util.ScreenManager;
import com.tiantian.app.R;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
 
 /** 
 * @author  William.Chen
 * @version 创建时间：2013-3-9 下午04:55:19 
 * 类说明         找回密码界面
 */
public class PageGetPasswordActivity extends SuperActivity {
	
	private final int STEP_ONE = 1;
	private final int STEP_TWO = 2;
	private final int STEP_THREE = 3;
 
	private Button backBtn,submitBtn;
	private int stepIndex ;
	
	private RelativeLayout layoutPhoneNum1,layoutVC2,layoutPassword3;
	
	
	/* 
	 * @see com.tiantian.app.activities.SuperActivity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_getpassword);
		onResetUI();
	}

	/* 
	 * @see com.tiantian.app.activities.SuperActivity#callback(java.lang.String, int, java.lang.Object)
	 */
	@Override
	public void callback(String type, int position, Object obj) {
		// TODO Auto-generated method stub

	}

	/* 
	 * @see com.tiantian.app.activities.SuperActivity#findView()
	 */
	@Override
	public void findView() {
		// TODO Auto-generated method stub
		superTitle = (TextView)findViewById(R.id.superTitle);
		superTitle.setText("忘记密码");
		
		backBtn = (Button)findViewById(R.id.superBack);
		backBtn.setVisibility(View.VISIBLE);
		
		submitBtn = (Button)findViewById(R.id.superSubmit);
		submitBtn.setVisibility(View.VISIBLE);
		
		layoutPhoneNum1 = (RelativeLayout)findViewById(R.id.layoutPhoneNum1);
		layoutVC2 = (RelativeLayout)findViewById(R.id.layoutVC2);
		layoutPassword3 = (RelativeLayout)findViewById(R.id.layoutPassword3);
		
	}

	/* 
	 * @see com.tiantian.app.activities.SuperActivity#initData()
	 */
	@Override
	public void initData() {
		// TODO Auto-generated method stub
		stepIndex = 1;
		updateLayoutUI();
	}
	
	private void updateLayoutUI(){
		layoutPhoneNum1.setVisibility(View.GONE);
		layoutVC2.setVisibility(View.GONE);
		layoutPassword3.setVisibility(View.GONE);
		switch(stepIndex){
		case STEP_ONE:
			submitBtn.setText("获取验证码");
			layoutPhoneNum1.setVisibility(View.VISIBLE);
			break;
		case STEP_TWO:
			submitBtn.setText("确认");
			layoutVC2.setVisibility(View.VISIBLE);
			break;
		case STEP_THREE:
			submitBtn.setText("确认");
			layoutPassword3.setVisibility(View.VISIBLE);
			break;
		}
	}

	/* 
	 * @see com.tiantian.app.activities.SuperActivity#onResetUI()
	 */
	@Override
	public void onResetUI() {
		// TODO Auto-generated method stub
		findView();
		setListener();
		initData();

	}

	/* 
	 * @see com.tiantian.app.activities.SuperActivity#setListener()
	 */
	@Override
	public void setListener() {
		// TODO Auto-generated method stub
        backBtn.setOnClickListener(this);
        submitBtn.setOnClickListener(this);
        
	}
	
	/* 
	 * @see com.tiantian.app.activities.SuperActivity#onClick(android.view.View)
	 */
	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		super.onClick(view);
		
		switch(view.getId()){
		case R.id.superBack:
			stepIndex--;
			if(stepIndex==0){
				ScreenManager.getScreenManager().popActivity(this);
			}else{
				updateLayoutUI();
			}
			break;
		case R.id.superSubmit:
			if(stepIndex<3){
				stepIndex++;
				updateLayoutUI();
			}
			break;
		}
	}

}
